package com.upb.webserver.common.enums;

import lombok.AllArgsConstructor;

/**
 * chain's type of fisco-bcos and hyperledger-fabric
 */
@AllArgsConstructor
public enum ChainTypeEnum {
    FISCO(0, "FISCO BCOS"),
    FABRIC(1, "Hyperledger Fabric");

    private byte id;
    private String description;


    ChainTypeEnum(int id, String description) {
        this.id = (byte) id;
        this.description = description;
    }

    public byte getId() {
        return this.id;
    }

    /**
     * @param id
     * @return
     */
    public static ChainTypeEnum getById(byte id) {
        for (ChainTypeEnum value : ChainTypeEnum.values()) {
            if (value.id == id) {
                return value;
            }
        }
        return null;
    }
}
